package com.smartjobs.action;

import com.opensymphony.xwork2.ActionSupport;
import com.smartjobs.loader.RDFLoader;
import com.smartjobs.reasoner.ReasonerQuery;
import com.smartjobs.bean.JobSeekerVO;
import java.util.ArrayList;

@SuppressWarnings("serial")
public class JobSeekersAction extends ActionSupport {

	ArrayList<JobSeekerVO> jobseekers = new ArrayList<JobSeekerVO>();
	String skill = "";

	public String getSkill() {
		return skill;
	}

	public void setSkill(String skill) {
		this.skill = skill;
	}

	public ArrayList<JobSeekerVO> getJobseekers() {
		return jobseekers;
	}

	public void setJobseekers(ArrayList<JobSeekerVO> jobseekers) {
		this.jobseekers = jobseekers;
	}

	public String execute() {
		int i;
		ArrayList<JobSeekerVO> jobSeekerList = new ArrayList<JobSeekerVO>();
		RDFLoader.loadFromDataBase();
		jobSeekerList = new ReasonerQuery().getAllJobSeekers();
		if (skill.equalsIgnoreCase("")) {
			jobseekers = jobSeekerList;
		} else {
			for (i = 0; i < jobSeekerList.size(); i++) {
				if (jobSeekerList.get(i).getSkills() != null) {
					if (jobSeekerList.get(i).getSkills().toLowerCase()
							.contains(skill.toLowerCase())) {
						jobseekers.add(jobSeekerList.get(i));
					}
				}
			}
		}
		return SUCCESS;
	}

	public String init() {
		return SUCCESS;

	}

}
